<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="所属项目" prop="projectId">
        <el-select clearable @change="handleQuery" v-model="queryParams.projectId" placeholder="请选择项目">
          <el-option v-for="item in projectOptions" :key="item.id" :label="item.projectName" :value="item.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="施工日期" prop="reportDate">
        <el-date-picker v-model="queryParams.reportDate" type="date" placeholder="请选择施工日期" value-format="yyyy-MM-dd"
          clearable @change="handleQuery" style="width: 200px" />
      </el-form-item>
      <!-- <el-form-item label="填报人" prop="createBy">
        <el-input v-model="queryParams.createBy" placeholder="请输入填报人" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="累计完成产值" prop="totalOutput">
        <el-input v-model="queryParams.totalOutput" placeholder="请输入累计完成产值" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="累计成本" prop="totalCost">
        <el-input v-model="queryParams.totalCost" placeholder="请输入累计成本" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="累计实现利润" prop="totalProfit">
        <el-input v-model="queryParams.totalProfit" placeholder="请输入累计实现利润" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="当日利润率" prop="dailyProfitRate">
        <el-input v-model="queryParams.dailyProfitRate" placeholder="请输入当日利润率" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="累计实现利润率" prop="totalProfitRate">
        <el-input v-model="queryParams.totalProfitRate" placeholder="请输入累计实现利润率" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['production:projectProfitReport:add']">新增</el-button>
      </el-col>

      <!-- <el-col :span="1.5">
        <el-button type="info" icon="el-icon-view" size="mini" :disabled="single" @click="handleDetail"
          v-hasPermi="['production:projectProfitReport:edit']">详情</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['production:projectProfitReport:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['production:projectProfitReport:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="projectProfitReportList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="ID" align="center" prop="id" /> -->
      <el-table-column label="名称" align="center" prop="dailyOutput">
        <template slot-scope="scope">
          {{ getDateOnly(scope.row.reportDate) + "日成本分析" }}
        </template>
      </el-table-column>
      <el-table-column label="填报时间" align="center" prop="dailyCost">
        <template slot-scope="scope">
          {{ changeTime(scope.row.createTime) }}
        </template>
      </el-table-column>
      <el-table-column label="填报人" align="center" prop="createBy" />
      <el-table-column label="所属项目" align="center" prop="projectId" width="170">
        <template slot-scope="scope">
          <el-tooltip class="item" effect="dark" :content="getProjectNameById(scope.row.projectId)" placement="top">
            <span
              style="max-width: 120px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;"
              :title="getProjectNameById(scope.row.projectId)">
              {{ getProjectNameById(scope.row.projectId) }}
            </span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="当日利润率" align="center" prop="dailyProfitRate">
        <template slot-scope="scope">
          {{ scope.row.dailyProfitRate != null
            ? Number(scope.row.dailyProfitRate * 100).toFixed(2) + "%"
            : "--" }}
        </template>
      </el-table-column>
      <el-table-column label="累计实现利润率" align="center" prop="totalProfit">
        <template slot-scope="scope">
          {{ scope.row.totalProfitRate != null
            ? Number(scope.row.totalProfitRate * 100).toFixed(2) + "%"
            : "--" }}
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)">详情</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['production:projectProfitReport:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改项目产值利润报对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="选择项目" prop="projectId">
          <el-select v-model="form.projectId" placeholder="请选择项目">
            <el-option v-for="item in projectOptions" :key="item.id" :label="item.projectName" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="选择日期" prop="date">
          <el-date-picker v-model="form.date" type="date" placeholder="请选择日期" value-format="yyyy-MM-dd"
            style="width: 100%" />
        </el-form-item>
        <el-form-item label="上传文件" prop="excelFile">
          <el-upload ref="upload" action="#" :auto-upload="false" :show-file-list="true" :limit="1"
            :before-upload="beforeUpload" :on-change="handleFileChange" :file-list="fileList" accept=".xls,.xlsx" drag>
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <div class="upload-tip">仅支持 .xls, .xlsx 格式文件，文件大小不超过 10MB</div>
          </el-upload>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 详情弹窗 -->
    <el-dialog :visible.sync="detailOpen" width="900px" :show-close="true" append-to-body class="daily-detail-dialog">
      <div class="daily-detail-title">项目产值利润详情</div>

      <div class="daily-section-title">基本信息</div>
      <div class="daily-row-flex">
        <div class="daily-col-flex">
          <table class="daily-detail-table">
            <tr>
              <th class="left-align">项目</th>
              <td class="value">
                {{ getProjectNameById(detailData && detailData.projectId) }}
              </td>
            </tr>
            <tr>
              <th class="left-align">日期</th>
              <td class="value">
                {{ getDateOnly(detailData && detailData.reportDate) }}
              </td>
            </tr>
            <tr>
              <th class="left-align">填报人</th>
              <td class="value">{{ detailData && detailData.createBy }}</td>
            </tr>
            <tr>
              <th class="left-align">填报时间</th>
              <td class="value">
                {{ changeTime(detailData && detailData.createTime) }}
              </td>
            </tr>
          </table>
        </div>
        <!-- <div class="daily-col-flex">
          <table class="daily-detail-table">
            <tr>
              <th class="left-align">项目</th>
              <td class="value">{{ getProjectNameById(detailData && detailData.projectId) }}</td>
            </tr>
            <tr>
              <th class="left-align">日期</th>
              <td class="value">{{ getDateOnly(detailData && detailData.reportDate) }}</td>
            </tr>
            <tr>
              <th class="left-align">填报人</th>
              <td class="value">{{ detailData && detailData.createBy }}</td>
            </tr>
            <tr>
              <th class="left-align">填报时间</th>
              <td class="value">{{ changeTime(detailData && detailData.createTime) }}</td>
            </tr>
          </table>
        </div> -->
      </div>

      <div class="daily-section-title">产值与利润</div>
      <table class="daily-detail-table">
        <tr>
          <th class="center-bg">当日产值</th>
          <td class="value">{{ detailData && detailData.dailyOutput }}</td>
          <th class="center-bg">当日成本</th>
          <td class="value">{{ detailData && detailData.dailyCost }}</td>
        </tr>
        <tr>
          <th class="center-bg">当日实现利润</th>
          <td class="value">{{ detailData && detailData.dailyProfit }}</td>
          <th class="center-bg">当日利润率</th>
          <td class="value">
            {{
              detailData && detailData.dailyProfitRate != null
                ? Number(detailData.dailyProfitRate * 100).toFixed(2) + "%"
                : ""
            }}
          </td>
        </tr>
        <tr>
          <th class="center-bg">累计实现利润率</th>
          <td class="value">
            {{
              detailData && detailData.totalProfitRate != null
                ? Number(detailData.totalProfitRate * 100).toFixed(2) + "%"
                : ""
            }}
          </td>
          <th class="center-bg">累计完成产值</th>
          <td class="value">{{ detailData && detailData.totalOutput }}</td>
        </tr>
        <!-- <tr>
          <th class="center-bg">前日累计成本</th>
          <td class="value">{{ detailData && detailData.previousCumulativeCost }}</td>
          <th class="center-bg">前日累计产值</th>
          <td class="value">{{ detailData && detailData.previousCumulativeOutput }}</td>
        </tr> -->
        <tr>
          <th class="center-bg">累计成本</th>
          <td class="value">{{ detailData && detailData.totalCost }}</td>
          <th class="center-bg">累计实现利润</th>
          <td class="value">{{ detailData && detailData.totalProfit }}</td>
        </tr>
      </table>

      <div class="daily-section-title">附件</div>
      <table class="daily-detail-table">
        <tr v-if="detailData && detailData.downloadurl">
          <th class="center-bg">附件</th>
          <td class="value">
            <i class="el-icon-document"></i>
            <a href="javascript:void(0);" download style="
                margin-left: 4px;
                color: #409eff;
                text-decoration: underline;
              " @click="
                handleDownload({
                  downloadUrl: detailData.downloadurl,
                  fileName: detailData.attachmentName,
                })
                ">
              {{ detailData.attachmentName || "下载附件" }}
            </a>
            <el-button type="primary" size="mini" icon="el-icon-view" style="margin-left: 8px;" @click="handlePreview({
              downloadUrl: detailData.downloadurl,
              fileName: detailData.attachmentName,
            })">
              预览
            </el-button>
          </td>
        </tr>
        <tr v-else>
          <th class="center-bg">附件</th>
          <td class="value">无</td>
        </tr>
      </table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="detailOpen = false" type="primary" plain>关闭</el-button>
      </span>
    </el-dialog>

    <!-- 文件预览弹框 -->
    <el-dialog :visible.sync="previewDialogVisible" width="60vw" top="5vh" :title="getPreviewTitle()"
      @close="previewFile = null">
      <div v-if="previewFile">
        <!-- Excel文件预览：直接用iframe打开 -->
        <iframe :src="previewFile.downloadUrl" style="width:100%;height:70vh;border:none;"></iframe>
      </div>
    </el-dialog>


  </div>
</template>

<script>
import {
  listProjectProfitReport,
  getProjectProfitReport,
  delProjectProfitReport,
  addProjectProfitReport,
  updateProjectProfitReport,
} from "@/api/production/projectProfitReport";
import {
  listProjectContractInfo,
  listProjectByUser,
  listAllProjectContractInfo,
} from "@/api/production/projectContractInfo";
import {
  fileLinkTransfer,
  fileLinkLooking,
} from "@/api/production/projectFileInfo";
import FileUpload from "@/components/FileUpload";

export default {
  name: "ProjectProfitReport",
  components: { FileUpload },
  data() {
    return {
      // 根路径
      baseURL: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 项目产值利润报表格数据
      projectProfitReportList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectId: null,
        reportDate: null,
        dailyOutput: null,
        dailyCost: null,
        dailyProfit: null,
        previousCumulativeOutput: null,
        previousCumulativeCost: null,
        totalOutput: null,
        totalCost: null,
        totalProfit: null,
        dailyProfitRate: null,
        totalProfitRate: null,
      },
      // 表单参数
      form: {
        // excelFile: '',
        date: "",
        projectId: "",
      },
      fileList: [], // 新增
      rawFile: null, // 新增
      projectOptions: [],
      dateOptions: [],
      // 表单校验
      rules: {
        id: [{ required: true, message: "ID不能为空", trigger: "blur" }],
        dailyOutput: [
          { required: true, message: "当日产值不能为空", trigger: "blur" },
        ],
        dailyCost: [
          { required: true, message: "当日成本不能为空", trigger: "blur" },
        ],
        dailyProfit: [
          { required: true, message: "当日实现利润不能为空", trigger: "blur" },
        ],
        previousCumulativeOutput: [
          { required: true, message: "前日累计产值不能为空", trigger: "blur" },
        ],
        previousCumulativeCost: [
          { required: true, message: "前日累计成本不能为空", trigger: "blur" },
        ],
        totalOutput: [
          { required: true, message: "累计完成产值不能为空", trigger: "blur" },
        ],
        totalCost: [
          { required: true, message: "累计成本不能为空", trigger: "blur" },
        ],
        totalProfit: [
          { required: true, message: "累计实现利润不能为空", trigger: "blur" },
        ],
        dailyProfitRate: [
          { required: true, message: "当日利润率不能为空", trigger: "blur" },
        ],
        totalProfitRate: [
          {
            required: true,
            message: "累计实现利润率不能为空",
            trigger: "blur",
          },
        ],
      },
      detailOpen: false,
      detailData: null,
      previewDialogVisible: false, // 新增：预览弹框的可见性
      previewFile: null, // 新增：预览文件的数据
    };
  },
  created() {
    this.fetchProjectOptions(); // 获取项目
    this.getList();
  },
  methods: {
    async handleDownload(file) {
      if (!file.downloadUrl) {
        this.$message.error("无效的下载链接");
        return;
      }
      try {
        const res = await fileLinkTransfer(file.downloadUrl);
        // 假设接口返回 { url: '新下载链接' }
        const newUrl = res.data.url;
        if (!newUrl) {
          this.$message.error("获取下载链接失败");
          return;
        }
        // 创建a标签下载
        const a = document.createElement("a");
        a.href = newUrl;
        a.download = file.fileName || "";
        a.target = "_blank";
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
      } catch (e) {
        this.$message.error("下载失败");
      }
    },
    /** 查询项目产值利润报列表 */
    getList() {
      this.loading = true;
      listProjectProfitReport(this.queryParams).then((response) => {
        this.projectProfitReportList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        // excelFile: '',
        date: "",
        projectId: "",
      };
      this.fileList = [];
      this.rawFile = null;
      this.resetForm && this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.reportDate = null;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "导入项目产值利润报";

      // this.generateDateOptions(); // This line is no longer needed
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getProjectProfitReport(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改项目产值利润报";
      });
    },
    handleFileChange(file, fileList) {
      this.fileList = fileList.slice(-1); // 只保留最新的一个
      if (fileList.length > 0) {
        this.rawFile = file.raw;
      } else {
        this.rawFile = null;
      }
    },
    beforeUpload(file) {
      const isExcel =
        file.type === "application/vnd.ms-excel" ||
        file.type ===
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
      const isLt10M = file.size / 1024 / 1024 < 10;
      if (!isExcel) {
        this.$message.error("只能上传 xls/xlsx 文件");
        return false;
      }
      if (!isLt10M) {
        this.$message.error("文件大小不能超过 10MB");
        return false;
      }
      return true;
    },
    async submitForm() {
      if (!this.rawFile) {
        this.$modal.msgError("请上传Excel文件");
        return;
      }
      if (!this.form.date) {
        this.$modal.msgError("请选择日期");
        return;
      }
      if (!this.form.projectId) {
        this.$modal.msgError("请选择项目");
        return;
      }
      // 用 FormData 方式上传
      const formData = new FormData();
      formData.append("file", this.rawFile);
      formData.append("reportDate", this.form.date);
      formData.append("projectId", this.form.projectId);
      addProjectProfitReport(formData).then((response) => {
        this.$modal.msgSuccess("导入成功");
        this.open = false;
        this.getList();
        this.fileList = [];
        this.rawFile = null;
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm("是否确认删除？")
        .then(function () {
          return delProjectProfitReport(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "production/projectProfitReport/export",
        {
          ...this.queryParams,
        },
        `projectProfitReport_${new Date().getTime()}.xlsx`
      );
    },
    // 获取项目列表
    fetchProjectOptions() {
      listAllProjectContractInfo().then((res) => {
        // console.log(1, res);
        this.projectOptions = res.data || [];
        // 默认选中第一个项目
        if (this.projectOptions.length == 1 && !this.queryParams.projectId) {
          this.queryParams.projectId = this.projectOptions[0].id;
          this.handleQuery();
        }
      });
    },
    /** 根据项目ID获取项目名称 */
    getProjectNameById(projectId) {
      // console.log(2, projectId, this.projectOptions);
      const item = this.projectOptions.find((p) => p.id == projectId);
      return item ? item.projectName : projectId;
    },
    // generateDateOptions() { // This function is no longer needed
    //   // 生成最近30天日期
    //   const today = new Date();
    //   const arr = [];
    //   for (let i = 0; i < 30; i++) {
    //     const d = new Date(today);
    //     d.setDate(today.getDate() - i);
    //     arr.push(d.toISOString().slice(0, 10));
    //   }
    //   this.dateOptions = arr;
    // }
    /** 详情按钮操作 */
    handleDetail(row) {
      const id =
        row && row.id ? row.id : this.ids.length === 1 ? this.ids[0] : null;
      if (!id) {
        this.$modal.msgError("请选择一条数据");
        return;
      }
      getProjectProfitReport(id).then((response) => {
        this.detailData = response.data;
        this.detailOpen = true;
      });
    },
    changeTime(time) {
      if (!time) return "";
      const date = new Date(time);
      if (isNaN(date.getTime())) return time;
      const pad = (n) => (n < 10 ? "0" + n : n);
      const y = date.getFullYear();
      const m = pad(date.getMonth() + 1);
      const d = pad(date.getDate());
      const h = pad(date.getHours());
      const min = pad(date.getMinutes());
      const s = pad(date.getSeconds());
      return `${y}-${m}-${d} ${h}:${min}:${s}`;
    },
    // 只保留年月日
    getDateOnly(datetime) {
      if (!datetime) return "";
      // 兼容字符串和Date对象
      const str =
        typeof datetime === "string" ? datetime : this.changeTime(datetime);
      // 匹配 yyyy-MM-dd
      const match = str.match(/^\d{4}-\d{2}-\d{2}/);
      return match ? match[0] : str;
    },
    // 预览文件
    async handlePreview(file) {
      if (!file.downloadUrl) {
        this.$message.error("无效的预览链接");
        return;
      }
      try {
        // 直接使用fileLinkLooking获取Excel预览链接
        const res = await fileLinkLooking(file.downloadUrl);
        const newUrl = res.data.url;
        if (!newUrl) {
          this.$message.error("获取预览链接失败");
          return;
        }

        // 设置预览文件信息并显示预览弹框
        this.previewFile = { ...file, downloadUrl: newUrl };
        this.previewDialogVisible = true;
      } catch (e) {
        this.$message.error("预览失败");
      }
    },
    // 获取预览标题
    getPreviewTitle() {
      if (this.previewFile && this.previewFile.fileName) {
        return this.previewFile.fileName;
      }
      return "Excel文件预览";
    },

  },
};
</script>

<style scoped>
.daily-detail-dialog .el-dialog__body {
  background: #f4f6fb;
  padding: 0;
}

.daily-detail-title {
  font-size: 22px;
  font-weight: bold;
  color: #2d3a4b;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 2px;
}

.daily-section-title {
  font-size: 18px;
  color: #4a90e2;
  font-weight: bold;
  margin: 32px 0 16px 0;
  border-left: 4px solid #4a90e2;
  padding-left: 12px;
  letter-spacing: 1px;
}

.daily-row-flex {
  display: flex;
  gap: 32px;
  margin-bottom: 12px;
}

.daily-col-flex {
  flex: 1;
}

.daily-detail-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: none;
}

.daily-detail-table th,
.daily-detail-table td {
  padding: 10px 8px;
  font-size: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.daily-detail-table th {
  width: 120px;
  color: #6b7a90;
  background: none;
  font-weight: normal;
  text-align: right;
  vertical-align: top;
  padding-right: 12px;
}

.daily-detail-table td.value {
  color: #222;
  text-align: left;
  font-weight: 500;
}

.daily-detail-table tr:last-child td,
.daily-detail-table tr:last-child th {
  border-bottom: none;
}

.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 6px;
  opacity: 0.7;
}

.daily-detail-table th.left-align {
  text-align: center;
  padding-left: 0;
  padding-right: 0;
  background: #f7fafd;
}

.daily-detail-table th.center-bg {
  text-align: center;
  vertical-align: middle;
  background: #f7fafd;
  width: 180px;
}

@media (max-width: 900px) {
  .daily-row-flex {
    flex-direction: column;
    gap: 0;
  }
}

@media (max-width: 600px) {
  .daily-detail-title {
    font-size: 20px;
  }

  .daily-section-title {
    font-size: 15px;
    padding-left: 8px;
  }

  .daily-detail-table th,
  .daily-detail-table td {
    font-size: 13px;
    padding: 7px 4px;
  }
}

/* 拖拽上传区域样式 */
.el-upload-dragger {
  width: 100%;
  height: 180px;
  border: 2px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}

.el-upload-dragger:hover {
  border-color: #409eff;
}

.el-upload-dragger.is-dragover {
  border-color: #409eff;
  background-color: #f0f9ff;
}

.el-upload-dragger .el-icon-upload {
  font-size: 67px;
  color: #c0c4cc;
  margin: 40px 0 16px;
  line-height: 50px;
}

.el-upload-dragger .el-upload__text {
  color: #606266;
  font-size: 14px;
  text-align: center;
  margin-bottom: 10px;
}

.el-upload-dragger .el-upload__text em {
  color: #409eff;
  font-style: normal;
  font-weight: bold;
}

.upload-tip {
  font-size: 12px;
  color: #909399;
  text-align: center;
  line-height: 1.5;
}

/* 拖拽悬停状态 */
.el-upload-dragger.is-dragover .el-icon-upload {
  color: #409eff;
}

.el-upload-dragger.is-dragover .el-upload__text {
  color: #409eff;
}

/* 文件列表样式优化 */
.el-upload-list {
  margin-top: 10px;
}

.el-upload-list__item {
  border-radius: 4px;
  border: 1px solid #e4e7ed;
  background-color: #fafafa;
}

.el-upload-list__item:hover {
  background-color: #f0f9ff;
  border-color: #409eff;
}
</style>
